package cn.codergege.demo.controller

import cn.codergege.demo.dao.PersonRepository
import cn.codergege.demo.service.PersonService
import cn.codergege.demo.utils.toDate
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping

@RequestMapping("/thymeleaf")
@Controller
class ThymeleafController {
    @Autowired
    lateinit var personService: PersonService
    @Autowired
    lateinit var personRepository: PersonRepository

    @RequestMapping("/demo")
    fun demoPage(map: MutableMap<String, Any>): String {
        map["date"] = "1986-05-29".toDate()
        val persons = personRepository.findAll()
        map["persons"] = persons
        return "/thymeleaf/demo"
    }
}
